package com.xiguanlezz.cn.common.utils;

/**
 * @Author：习惯了种种
 * @CreateDate：2024/11/28 13:28
 * @Description：线程工具类
 */
public class ThreadUtils {

    private static final int THREAD_MULTIPLER = 2;


    private ThreadUtils() {
    }

    public static int getSuitableThreadCount() {
        return getSuitableThreadCount(THREAD_MULTIPLER);
    }

    public static int getSuitableThreadCount(int threadMultiple) {
        final int coreCount = PropertyUtils.getProcessorsCount();
        int workerCount = 1;
        while (workerCount < coreCount * threadMultiple) {
            workerCount <<= 1;
        }
        return workerCount;
    }
}
